package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.service
 * @Description:
 * @Date 2022/6/16 18:56
 */
@Service
public class DtsPermissionServiceImpl implements DtsPermissionService {

    @Autowired
    private DtsPermissionMapper dtsPermissionMapper;
    @Override
    public Set<String> queryByRoleIds(Integer[] roleIds) {
        Set<String> set = new HashSet<>();
        if(roleIds==null||roleIds.length==0){
            return set;
        }
        QueryWrapper<DtsPermission> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.in("role_id", roleIds);
        objectQueryWrapper.eq("deleted", false);
        List<DtsPermission> list = dtsPermissionMapper.selectList(objectQueryWrapper);
        for (DtsPermission dtsPermission : list) {
            //把权限放入集合中
             set.add(dtsPermission.getPermission());
        }


        return set;
    }


}
